var layer = require('{pub}/layer');
var tpl = require('../../views/adduser');
var data = require('{pub}/data');

return function(e, elem, _layer, callback){
    layer.form({
        content:tpl,
        title:'增加员工',
        under:_layer,
        ajax:{
            url:'emp/add'
        },
        onInit:function(){

        },
        onSuccess:function(self, res, xhr){
            data.set('empList');
            if(res.status == '200'){
                if(typeof callback === 'function'){
                    callback.apply(this, arguments);
                }
                self.destroy()
            }
        },
        onBeforeSubmit:function(self, params){
            params.mobile = params.mobile.replace(/\s/g, '');
            return params
        }
    })
}